﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using gfLibrary;
using DBUtility;
using Model;
using BLL;

namespace GreatGF
{
    public partial class TYPE_CX_CONTENT_Insert_Update : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Page.IsPostBack == false)
            {

                string strMode = Request["m"];

                if((strMode == "u")||(strMode == "b")||(strMode == "r"))
                {
                    string strId = Request["UniqueKey"];

                    TYPE_CX_CONTENT_BLL m_TYPE_CX_CONTENT_BLL = new TYPE_CX_CONTENT_BLL();

                    if(m_TYPE_CX_CONTENT_BLL.Exists(Convert.ToInt32(strId)) == true)
                    {
                        TYPE_CX_CONTENT m_TYPE_CX_CONTENT = new TYPE_CX_CONTENT();
                        m_TYPE_CX_CONTENT = m_TYPE_CX_CONTENT_BLL.GetModel(Convert.ToInt32(strId));

                        txtID.Text = m_TYPE_CX_CONTENT.ID.ToString();
                        txtCPMC.Text = m_TYPE_CX_CONTENT.CPMC;
                        txtPP.Text = m_TYPE_CX_CONTENT.PP;
                        txtXH.Text = m_TYPE_CX_CONTENT.XH;
                        txtPPXH.Text = m_TYPE_CX_CONTENT.PPXH;
                        txtCXDM.Text = m_TYPE_CX_CONTENT.CXDM;
                        txtSFDABS.Text = m_TYPE_CX_CONTENT.SFDABS;
                        txtABSZWZ.Text = m_TYPE_CX_CONTENT.ABSZWZ;
                        txtQDXS.Text = m_TYPE_CX_CONTENT.QDXS;
                        txtQDZWZ.Text = m_TYPE_CX_CONTENT.QDZWZ;
                        txtZCZWZ.Text = m_TYPE_CX_CONTENT.ZCZWZ;
                        txtQZDZ.Text = m_TYPE_CX_CONTENT.QZDZ;
                        txtZBZL.Text = m_TYPE_CX_CONTENT.ZBZL;
                        txtZZL.Text = m_TYPE_CX_CONTENT.ZZL;
                        txtHDZH.Text = m_TYPE_CX_CONTENT.HDZH;
                        txtZZS.Text = m_TYPE_CX_CONTENT.ZZS;
                        txtCYS.Text = m_TYPE_CX_CONTENT.CYS;
                        txtZGSJCS.Text = m_TYPE_CX_CONTENT.ZGSJCS;
                        txtZDFS.Text = m_TYPE_CX_CONTENT.ZDFS;
                        txtCLZL.Text = m_TYPE_CX_CONTENT.CLZL;
                        txtZXZXJXS.Text = m_TYPE_CX_CONTENT.ZXZXJXS;
                        txtZXZLX.Text = m_TYPE_CX_CONTENT.ZXZLX;
                        txtBSXLX.Text = m_TYPE_CX_CONTENT.BSXLX;
                        txtLTQY.Text = m_TYPE_CX_CONTENT.LTQY;
                        txtLTGG.Text = m_TYPE_CX_CONTENT.LTGG;
                        txtLTGGLX.Text = m_TYPE_CX_CONTENT.LTGGLX;
                        txtLTSL.Text = m_TYPE_CX_CONTENT.LTSL;
                        txtCSC.Text = m_TYPE_CX_CONTENT.CSC;
                        txtCSK.Text = m_TYPE_CX_CONTENT.CSK;
                        txtCSG.Text = m_TYPE_CX_CONTENT.CSG;
                        txtZJ.Text = m_TYPE_CX_CONTENT.ZJ;
                        txtBZZXS.Text = m_TYPE_CX_CONTENT.BZZXS;
                        txtYZLJ.Text = m_TYPE_CX_CONTENT.YZLJ;
                        txtEZLJ.Text = m_TYPE_CX_CONTENT.EZLJ;
                        txtSZLJ.Text = m_TYPE_CX_CONTENT.SZLJ;
                        txtSIZLJ.Text = m_TYPE_CX_CONTENT.SIZLJ;
                        txtWZLJ.Text = m_TYPE_CX_CONTENT.WZLJ;
                        txtLZLJ.Text = m_TYPE_CX_CONTENT.LZLJ;
                        txtYZZLZ.Text = m_TYPE_CX_CONTENT.YZZLZ;
                        txtYZYLZ.Text = m_TYPE_CX_CONTENT.YZYLZ;
                        txtYZZZ.Text = m_TYPE_CX_CONTENT.YZZZ;
                        txtEZZLZ.Text = m_TYPE_CX_CONTENT.EZZLZ;
                        txtEZYLZ.Text = m_TYPE_CX_CONTENT.EZYLZ;
                        txtEZZZ.Text = m_TYPE_CX_CONTENT.EZZZ;
                        txtSZZLZ.Text = m_TYPE_CX_CONTENT.SZZLZ;
                        txtSZYLZ.Text = m_TYPE_CX_CONTENT.SZYLZ;
                        txtSZZZ.Text = m_TYPE_CX_CONTENT.SZZZ;
                        txtSIZZLZ.Text = m_TYPE_CX_CONTENT.SIZZLZ;
                        txtSIZYLZ.Text = m_TYPE_CX_CONTENT.SIZYLZ;
                        txtSIZZZ.Text = m_TYPE_CX_CONTENT.SIZZZ;
                        txtWZZLZ.Text = m_TYPE_CX_CONTENT.WZZLZ;
                        txtWZYLZ.Text = m_TYPE_CX_CONTENT.WZYLZ;
                        txtWZZZ.Text = m_TYPE_CX_CONTENT.WZZZ;
                        txtLZZLZ.Text = m_TYPE_CX_CONTENT.LZZLZ;
                        txtLZYLZ.Text = m_TYPE_CX_CONTENT.LZYLZ;
                        txtLZZZ.Text = m_TYPE_CX_CONTENT.LZZZ;
                        txtQDZKZZL.Text = m_TYPE_CX_CONTENT.QDZKZZL;
                    }
                    else
                    {
                        gfAjaxJs.SetAlertMsg(this.UpdatePanel1, "请选择一条记录！");
                        gfAjaxJs.SetGoToUrl(this.UpdatePanel1, "TYPE_CX_CONTENT_List.aspx");
                    }

                    if((strMode == "b")||(strMode == "r"))
                    {
                        txtID.ReadOnly = true;
                        txtID.CssClass = "csstextboxreadonly";
                        txtCPMC.ReadOnly = true;
                        txtCPMC.CssClass = "csstextboxreadonly";
                        txtPP.ReadOnly = true;
                        txtPP.CssClass = "csstextboxreadonly";
                        txtXH.ReadOnly = true;
                        txtXH.CssClass = "csstextboxreadonly";
                        txtPPXH.ReadOnly = true;
                        txtPPXH.CssClass = "csstextboxreadonly";
                        txtCXDM.ReadOnly = true;
                        txtCXDM.CssClass = "csstextboxreadonly";
                        txtSFDABS.ReadOnly = true;
                        txtSFDABS.CssClass = "csstextboxreadonly";
                        txtABSZWZ.ReadOnly = true;
                        txtABSZWZ.CssClass = "csstextboxreadonly";
                        txtQDXS.ReadOnly = true;
                        txtQDXS.CssClass = "csstextboxreadonly";
                        txtQDZWZ.ReadOnly = true;
                        txtQDZWZ.CssClass = "csstextboxreadonly";
                        txtZCZWZ.ReadOnly = true;
                        txtZCZWZ.CssClass = "csstextboxreadonly";
                        txtQZDZ.ReadOnly = true;
                        txtQZDZ.CssClass = "csstextboxreadonly";
                        txtZBZL.ReadOnly = true;
                        txtZBZL.CssClass = "csstextboxreadonly";
                        txtZZL.ReadOnly = true;
                        txtZZL.CssClass = "csstextboxreadonly";
                        txtHDZH.ReadOnly = true;
                        txtHDZH.CssClass = "csstextboxreadonly";
                        txtZZS.ReadOnly = true;
                        txtZZS.CssClass = "csstextboxreadonly";
                        txtCYS.ReadOnly = true;
                        txtCYS.CssClass = "csstextboxreadonly";
                        txtZGSJCS.ReadOnly = true;
                        txtZGSJCS.CssClass = "csstextboxreadonly";
                        txtZDFS.ReadOnly = true;
                        txtZDFS.CssClass = "csstextboxreadonly";
                        txtCLZL.ReadOnly = true;
                        txtCLZL.CssClass = "csstextboxreadonly";
                        txtZXZXJXS.ReadOnly = true;
                        txtZXZXJXS.CssClass = "csstextboxreadonly";
                        txtZXZLX.ReadOnly = true;
                        txtZXZLX.CssClass = "csstextboxreadonly";
                        txtBSXLX.ReadOnly = true;
                        txtBSXLX.CssClass = "csstextboxreadonly";
                        txtLTQY.ReadOnly = true;
                        txtLTQY.CssClass = "csstextboxreadonly";
                        txtLTGG.ReadOnly = true;
                        txtLTGG.CssClass = "csstextboxreadonly";
                        txtLTGGLX.ReadOnly = true;
                        txtLTGGLX.CssClass = "csstextboxreadonly";
                        txtLTSL.ReadOnly = true;
                        txtLTSL.CssClass = "csstextboxreadonly";
                        txtCSC.ReadOnly = true;
                        txtCSC.CssClass = "csstextboxreadonly";
                        txtCSK.ReadOnly = true;
                        txtCSK.CssClass = "csstextboxreadonly";
                        txtCSG.ReadOnly = true;
                        txtCSG.CssClass = "csstextboxreadonly";
                        txtZJ.ReadOnly = true;
                        txtZJ.CssClass = "csstextboxreadonly";
                        txtBZZXS.ReadOnly = true;
                        txtBZZXS.CssClass = "csstextboxreadonly";
                        txtYZLJ.ReadOnly = true;
                        txtYZLJ.CssClass = "csstextboxreadonly";
                        txtEZLJ.ReadOnly = true;
                        txtEZLJ.CssClass = "csstextboxreadonly";
                        txtSZLJ.ReadOnly = true;
                        txtSZLJ.CssClass = "csstextboxreadonly";
                        txtSIZLJ.ReadOnly = true;
                        txtSIZLJ.CssClass = "csstextboxreadonly";
                        txtWZLJ.ReadOnly = true;
                        txtWZLJ.CssClass = "csstextboxreadonly";
                        txtLZLJ.ReadOnly = true;
                        txtLZLJ.CssClass = "csstextboxreadonly";
                        txtYZZLZ.ReadOnly = true;
                        txtYZZLZ.CssClass = "csstextboxreadonly";
                        txtYZYLZ.ReadOnly = true;
                        txtYZYLZ.CssClass = "csstextboxreadonly";
                        txtYZZZ.ReadOnly = true;
                        txtYZZZ.CssClass = "csstextboxreadonly";
                        txtEZZLZ.ReadOnly = true;
                        txtEZZLZ.CssClass = "csstextboxreadonly";
                        txtEZYLZ.ReadOnly = true;
                        txtEZYLZ.CssClass = "csstextboxreadonly";
                        txtEZZZ.ReadOnly = true;
                        txtEZZZ.CssClass = "csstextboxreadonly";
                        txtSZZLZ.ReadOnly = true;
                        txtSZZLZ.CssClass = "csstextboxreadonly";
                        txtSZYLZ.ReadOnly = true;
                        txtSZYLZ.CssClass = "csstextboxreadonly";
                        txtSZZZ.ReadOnly = true;
                        txtSZZZ.CssClass = "csstextboxreadonly";
                        txtSIZZLZ.ReadOnly = true;
                        txtSIZZLZ.CssClass = "csstextboxreadonly";
                        txtSIZYLZ.ReadOnly = true;
                        txtSIZYLZ.CssClass = "csstextboxreadonly";
                        txtSIZZZ.ReadOnly = true;
                        txtSIZZZ.CssClass = "csstextboxreadonly";
                        txtWZZLZ.ReadOnly = true;
                        txtWZZLZ.CssClass = "csstextboxreadonly";
                        txtWZYLZ.ReadOnly = true;
                        txtWZYLZ.CssClass = "csstextboxreadonly";
                        txtWZZZ.ReadOnly = true;
                        txtWZZZ.CssClass = "csstextboxreadonly";
                        txtLZZLZ.ReadOnly = true;
                        txtLZZLZ.CssClass = "csstextboxreadonly";
                        txtLZYLZ.ReadOnly = true;
                        txtLZYLZ.CssClass = "csstextboxreadonly";
                        txtLZZZ.ReadOnly = true;
                        txtLZZZ.CssClass = "csstextboxreadonly";
                        txtQDZKZZL.ReadOnly = true;
                        txtQDZKZZL.CssClass = "csstextboxreadonly";
                        btnSave.Visible = false;
                    }

                    if(strMode == "r")
                    {
                        btnBack.Visible = false;
                    }
                }
                if (strMode == "i")
                {
                    lblOperateType.Text = "添加";
                }
                if (strMode == "b" || strMode == "r")
                {
                    lblOperateType.Text = "查看";
                }
                if (strMode == "u")
                {
                    lblOperateType.Text = "修改";
                }
            }

            btnBack.Attributes["onclick"] = "window.history.back()";
        }

        protected void btnSave_Click(object sender, EventArgs e)
        {
            string strID = txtID.Text.Trim();
            string strCPMC = txtCPMC.Text.Trim();
            string strPP = txtPP.Text.Trim();
            string strXH = txtXH.Text.Trim();
            string strPPXH = txtPPXH.Text.Trim();
            string strCXDM = txtCXDM.Text.Trim();
            string strSFDABS = txtSFDABS.Text.Trim();
            string strABSZWZ = txtABSZWZ.Text.Trim();
            string strQDXS = txtQDXS.Text.Trim();
            string strQDZWZ = txtQDZWZ.Text.Trim();
            string strZCZWZ = txtZCZWZ.Text.Trim();
            string strQZDZ = txtQZDZ.Text.Trim();
            string strZBZL = txtZBZL.Text.Trim();
            string strZZL = txtZZL.Text.Trim();
            string strHDZH = txtHDZH.Text.Trim();
            string strZZS = txtZZS.Text.Trim();
            string strCYS = txtCYS.Text.Trim();
            string strZGSJCS = txtZGSJCS.Text.Trim();
            string strZDFS = txtZDFS.Text.Trim();
            string strCLZL = txtCLZL.Text.Trim();
            string strZXZXJXS = txtZXZXJXS.Text.Trim();
            string strZXZLX = txtZXZLX.Text.Trim();
            string strBSXLX = txtBSXLX.Text.Trim();
            string strLTQY = txtLTQY.Text.Trim();
            string strLTGG = txtLTGG.Text.Trim();
            string strLTGGLX = txtLTGGLX.Text.Trim();
            string strLTSL = txtLTSL.Text.Trim();
            string strCSC = txtCSC.Text.Trim();
            string strCSK = txtCSK.Text.Trim();
            string strCSG = txtCSG.Text.Trim();
            string strZJ = txtZJ.Text.Trim();
            string strBZZXS = txtBZZXS.Text.Trim();
            string strYZLJ = txtYZLJ.Text.Trim();
            string strEZLJ = txtEZLJ.Text.Trim();
            string strSZLJ = txtSZLJ.Text.Trim();
            string strSIZLJ = txtSIZLJ.Text.Trim();
            string strWZLJ = txtWZLJ.Text.Trim();
            string strLZLJ = txtLZLJ.Text.Trim();
            string strYZZLZ = txtYZZLZ.Text.Trim();
            string strYZYLZ = txtYZYLZ.Text.Trim();
            string strYZZZ = txtYZZZ.Text.Trim();
            string strEZZLZ = txtEZZLZ.Text.Trim();
            string strEZYLZ = txtEZYLZ.Text.Trim();
            string strEZZZ = txtEZZZ.Text.Trim();
            string strSZZLZ = txtSZZLZ.Text.Trim();
            string strSZYLZ = txtSZYLZ.Text.Trim();
            string strSZZZ = txtSZZZ.Text.Trim();
            string strSIZZLZ = txtSIZZLZ.Text.Trim();
            string strSIZYLZ = txtSIZYLZ.Text.Trim();
            string strSIZZZ = txtSIZZZ.Text.Trim();
            string strWZZLZ = txtWZZLZ.Text.Trim();
            string strWZYLZ = txtWZYLZ.Text.Trim();
            string strWZZZ = txtWZZZ.Text.Trim();
            string strLZZLZ = txtLZZLZ.Text.Trim();
            string strLZYLZ = txtLZYLZ.Text.Trim();
            string strLZZZ = txtLZZZ.Text.Trim();
            string strQDZKZZL = txtQDZKZZL.Text.Trim();


            TYPE_CX_CONTENT m_TYPE_CX_CONTENT = new TYPE_CX_CONTENT();
            TYPE_CX_CONTENT_BLL m_TYPE_CX_CONTENT_BLL = new TYPE_CX_CONTENT_BLL();

            m_TYPE_CX_CONTENT.CPMC = strCPMC;
            m_TYPE_CX_CONTENT.PP = strPP;
            m_TYPE_CX_CONTENT.XH = strXH;
            m_TYPE_CX_CONTENT.PPXH = strPPXH;
            m_TYPE_CX_CONTENT.CXDM = strCXDM;
            m_TYPE_CX_CONTENT.SFDABS = strSFDABS;
            m_TYPE_CX_CONTENT.ABSZWZ = strABSZWZ;
            m_TYPE_CX_CONTENT.QDXS = strQDXS;
            m_TYPE_CX_CONTENT.QDZWZ = strQDZWZ;
            m_TYPE_CX_CONTENT.ZCZWZ = strZCZWZ;
            m_TYPE_CX_CONTENT.QZDZ = strQZDZ;
            m_TYPE_CX_CONTENT.ZBZL = strZBZL;
            m_TYPE_CX_CONTENT.ZZL = strZZL;
            m_TYPE_CX_CONTENT.HDZH = strHDZH;
            m_TYPE_CX_CONTENT.ZZS = strZZS;
            m_TYPE_CX_CONTENT.CYS = strCYS;
            m_TYPE_CX_CONTENT.ZGSJCS = strZGSJCS;
            m_TYPE_CX_CONTENT.ZDFS = strZDFS;
            m_TYPE_CX_CONTENT.CLZL = strCLZL;
            m_TYPE_CX_CONTENT.ZXZXJXS = strZXZXJXS;
            m_TYPE_CX_CONTENT.ZXZLX = strZXZLX;
            m_TYPE_CX_CONTENT.BSXLX = strBSXLX;
            m_TYPE_CX_CONTENT.LTQY = strLTQY;
            m_TYPE_CX_CONTENT.LTGG = strLTGG;
            m_TYPE_CX_CONTENT.LTGGLX = strLTGGLX;
            m_TYPE_CX_CONTENT.LTSL = strLTSL;
            m_TYPE_CX_CONTENT.CSC = strCSC;
            m_TYPE_CX_CONTENT.CSK = strCSK;
            m_TYPE_CX_CONTENT.CSG = strCSG;
            m_TYPE_CX_CONTENT.ZJ = strZJ;
            m_TYPE_CX_CONTENT.BZZXS = strBZZXS;
            m_TYPE_CX_CONTENT.YZLJ = strYZLJ;
            m_TYPE_CX_CONTENT.EZLJ = strEZLJ;
            m_TYPE_CX_CONTENT.SZLJ = strSZLJ;
            m_TYPE_CX_CONTENT.SIZLJ = strSIZLJ;
            m_TYPE_CX_CONTENT.WZLJ = strWZLJ;
            m_TYPE_CX_CONTENT.LZLJ = strLZLJ;
            m_TYPE_CX_CONTENT.YZZLZ = strYZZLZ;
            m_TYPE_CX_CONTENT.YZYLZ = strYZYLZ;
            m_TYPE_CX_CONTENT.YZZZ = strYZZZ;
            m_TYPE_CX_CONTENT.EZZLZ = strEZZLZ;
            m_TYPE_CX_CONTENT.EZYLZ = strEZYLZ;
            m_TYPE_CX_CONTENT.EZZZ = strEZZZ;
            m_TYPE_CX_CONTENT.SZZLZ = strSZZLZ;
            m_TYPE_CX_CONTENT.SZYLZ = strSZYLZ;
            m_TYPE_CX_CONTENT.SZZZ = strSZZZ;
            m_TYPE_CX_CONTENT.SIZZLZ = strSIZZLZ;
            m_TYPE_CX_CONTENT.SIZYLZ = strSIZYLZ;
            m_TYPE_CX_CONTENT.SIZZZ = strSIZZZ;
            m_TYPE_CX_CONTENT.WZZLZ = strWZZLZ;
            m_TYPE_CX_CONTENT.WZYLZ = strWZYLZ;
            m_TYPE_CX_CONTENT.WZZZ = strWZZZ;
            m_TYPE_CX_CONTENT.LZZLZ = strLZZLZ;
            m_TYPE_CX_CONTENT.LZYLZ = strLZYLZ;
            m_TYPE_CX_CONTENT.LZZZ = strLZZZ;
            m_TYPE_CX_CONTENT.QDZKZZL = strQDZKZZL;

            if (string.IsNullOrEmpty(strID) == true)
            {
                strID = "-1";
            }

            if (m_TYPE_CX_CONTENT_BLL.Exists(Convert.ToInt32(strID)) == false)
            {
                //m_TYPE_CX_CONTENT.ID = m_TYPE_CX_CONTENT_BLL.GetMax_ID();

                if (m_TYPE_CX_CONTENT_BLL.Insert(m_TYPE_CX_CONTENT) == true)
                {
                    gfAjaxJs.SetAlertMsg(this.UpdatePanel1, "新增成功！");
                    txtID.Text = m_TYPE_CX_CONTENT.ID.ToString();
                }
                else
                {
                    gfAjaxJs.SetAlertMsg(this.UpdatePanel1, "新增失败！");
                }
            }
            else
            {
                if (m_TYPE_CX_CONTENT_BLL.Update(m_TYPE_CX_CONTENT, Convert.ToInt32(strID)) == true)
                {
                     gfAjaxJs.SetAlertMsg(this.UpdatePanel1, "更新成功！");
                }
                else
                {
                    gfAjaxJs.SetAlertMsg(this.UpdatePanel1, "更新失败！");
                }
            }
        }
    }
}
